<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>
    .StarsWrap {
        width: 100%;
        height: 0.2rem;
        margin: 0.1rem 0;
    }

    .StarsWrap li {
        float: left;
        margin-right: 0.1rem;
    }
</style>

<body>
    <div id="box">
        <ul class="StarsWrap">
            <li v-for="(i,index) in list" :key="index" @click="clickStars(index)">
                <img :src="xing>index?stara:starb" />
            </li>
        </ul>
        <p>{{rateScoreText}}</p>
    </div>
    <script>
        var vm = new Vue({
            el: '#box',
            data: {
                rateScoreText: '',
                rateScoreDesc: [],
                stara: './images/010.png',//亮星星
                list: [0, 1, 2, 3, 4],
                starb: './images/020.png',//暗星星
                xing: 0,
            },
            methods: {
                clickStars(i) {
                    this.rateScoreText = this.rateScoreDesc[i]
                    this.xing = i + 1
                    console.log("点击了" + (i + 1) + "颗星")
                }
            }
        });
    </script>


</body>

</html>